package com.lm.itextpdf.example;

import com.itextpdf.forms.PdfAcroForm;
import com.itextpdf.forms.fields.PdfFormField;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfWriter;

public class CreateFormPDFExample {
    public static void main(String[] args) throws Exception {
        String dest = "form_example.pdf";

        PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest));
        PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true);

        PdfFormField nameField = PdfFormField.createText(pdfDoc, new com.itextpdf.kernel.geom.Rectangle(100, 700, 200, 20), "Name");
        nameField.setValue("Enter your name here");

        form.addField(nameField);

        pdfDoc.close();
        System.out.println("PDF with form field created at: " + dest);
    }
}
